package co.edu.usbcali.unidad.modelo.dto;

import co.edu.usbcali.unidad.modelo.Rubro;
import co.edu.usbcali.unidad.presentation.backEndBeans.RubroView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;

/**
 * 
 * 
 * @author Zathura Code Generator http://code.google.com/p/zathura
 * 
 */
public class RubroDTO implements Serializable {
	private static final long serialVersionUID = 1L;
	private String rubNombre;
	private String rubCodigo;
	private boolean rowSelected = false;
	private RubroView rubroView;
	private Rubro rubro;

	public Rubro getRubro() {
		return rubro;
	}

	public String listener_update(ActionEvent e) {
		try {
			rubroView.action_modifyWitDTO(((rubCodigo == null) || rubCodigo
					.equals("")) ? null : new String(rubCodigo),
					((rubNombre == null) || rubNombre.equals("")) ? null
							: new String(rubNombre));
			rowSelected = !rowSelected;
		} catch (Exception ex) {
			return "";
		}

		return "";
	}

	public void listener_cancel(ActionEvent e) {
		rubCodigo = rubro.getRubCodigo().toString();
		rubNombre = (rubro.getRubNombre() != null) ? rubro.getRubNombre()
				.toString() : null;
		rowSelected = !rowSelected;
	}

	/**
	 * <p>
	 * Bound to commandLink actionListener in the ui that renders/unrenders the
	 * Customer details for editing.
	 * </p>
	 */
	public void toggleSelected(ActionEvent e) {
		rubCodigo = rubro.getRubCodigo().toString();
		rubNombre = (rubro.getRubNombre() != null) ? rubro.getRubNombre()
				.toString() : null;
		rowSelected = !rowSelected;
	}

	public void setRubro(Rubro rubro) {
		this.rubro = rubro;
	}

	public RubroView getRubroView() {
		return rubroView;
	}

	public void setRubroView(RubroView rubroView) {
		this.rubroView = rubroView;
	}

	public String getRubNombre() {
		return rubNombre;
	}

	public void setRubNombre(String rubNombre) {
		this.rubNombre = rubNombre;
	}

	public String getRubCodigo() {
		return rubCodigo;
	}

	public void setRubCodigo(String rubCodigo) {
		this.rubCodigo = rubCodigo;
	}

	public boolean isRowSelected() {
		return rowSelected;
	}

	public void setRowSelected(boolean rowSelected) {
		this.rowSelected = rowSelected;
	}
}
